--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Commit bec78cf1e55810fdb0bc98188a818138fca4cf27
Parents : ad10301
Author : Jeremy O'Brien <956a74d715fe9cb2e9da0a19b067b414>
Signature : T66BB85Valid, signed by author
Date : 2026-05-28T14:39:23-04:00
RRC: filter and *then* apply the history cap
Changes
Diff
diff --git a/nomadnet/RRC.py b/nomadnet/RRC.py
index 6a58845..e46d31c 100644
--- a/nomadnet/RRC.py
+++ b/nomadnet/RRC.py
@@ -720,6 +720,7 @@ class RRCHub:
def _load_history(self):
with self._lock:
rooms = list(self.messages.keys())
+ filter_msgs = self._filter_history()
for room in rooms:
if not self._persistable_room(room):
continue
@@ -732,38 +733,32 @@ class RRCHub:
with open(path, "rb") as f:
while True:
try:
- window.append(cbor.load(f))
+ entry = cbor.load(f)
except EOFError:
break
except Exception as ex:
decode_error = ex
break
+ m = self._msg_from_entry(room, entry)
+ if m is None:
+ continue
+ if filter_msgs and (m.kind == "system" or m.kind == "notice"):
+ continue
+ window.append(m)
except OSError as ex:
self._log("history load failed for #"+room+": "+str(ex), RNS.LOG_ERROR)
continue
if decode_error is not None:
self._log("history file for #"+room+" is corrupt, truncating to last "+str(len(window))+" valid messages: "+str(decode_error), RNS.LOG_ERROR)
- msgs = []
- filter_msgs = self._filter_history()
- for e in window:
- m = self._msg_from_entry(room, e)
- if m is not None:
- if filter_msgs:
- should_filter = False
- if m.kind == "system": should_filter = True
- elif m.kind == "notice": should_filter = True
- if should_filter: continue
-
- msgs.append(m)
with self._lock:
- self.messages[room] = msgs
+ self.messages[room] = list(window)
def _clean_history(self):
now = time.time()
cleaned = False
remove_after = self._ephemeral_notices_history()
if now > self._last_history_clean + self.CLEAN_HISTORY_INTERVAL:
- RNS.log(f"Cleaning loaded message history", RNS.LOG_DEBUG)
+ RNS.log(f"Cleaning loaded message history", RNS.LOG_DEBUG)
with self._lock:
try:
for r in self.messages:
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────